package com.ljy.my_study.spring.test20171107;

public class SpringMatchMain {
	public static void main(String[] args) {
		String a="12323";
		String pattern ="1*3*";
		System.out.println(match(a, pattern));
	}
	
	private static boolean match(String str,String pattern) {
		if(str==null||pattern==null) {
			return false;
		}
		int firstIndex=pattern.indexOf("*");
		if(firstIndex==-1&&str.contains(pattern)) {
			return true;
		}
		if(firstIndex==0) {
			int nextIndex=pattern.indexOf("*", 1);
			if(nextIndex==-1) {
				return str.substring(1).contains(pattern.substring(1));
			}
			return match(str.substring(1),pattern.substring(1));
		}
		return (str.substring(0, firstIndex).equals(pattern.substring(0, firstIndex))
				&&match(str.substring(firstIndex),pattern.substring(firstIndex)));
	}
	
	
}
